﻿using System;
using System.Windows.Navigation;


namespace MugenMvvmToolkit.Interfaces
{
    /// <summary>
    ///     Implemented by services that provide <see cref="IViewPageMappingItem" /> based navigation.
    /// </summary>
    public interface INavigationService
    {
        /// <summary>
        ///     Gets or sets the root page <see cref="IViewPageMappingItem" />
        /// </summary>
        IViewPageMappingItem RootItem { get; set; }

        /// <summary>
        ///     The <see cref="Uri" /> source.
        /// </summary>
        Uri Source { get; set; }

        /// <summary>
        ///     Indicates whether the navigator can navigate back.
        /// </summary>
        bool CanGoBack { get; }

        /// <summary>
        ///     Indicates whether the navigator can navigate forward.
        /// </summary>
        bool CanGoForward { get; }

        /// <summary>
        ///     The current <see cref="Uri" /> source.
        /// </summary>
        Uri CurrentSource { get; }

        /// <summary>
        ///     The current content.
        /// </summary>
        object CurrentContent { get; }

        /// <summary>
        ///     Stops the loading process.
        /// </summary>
        void StopLoading();

        /// <summary>
        ///     Navigates back.
        /// </summary>
        void GoBack();

        /// <summary>
        ///     Navigates forward.
        /// </summary>
        void GoForward();

        /// <summary>
        ///     Displays the content located at the specified <see cref="IViewPageMappingItem" />.
        /// </summary>
        /// <param name="uri">
        ///     The <c>Uri</c> of the content to display.
        /// </param>
        /// <returns>
        ///     <c>true</c> if the content was successfully displayed; otherwise, <c>false</c>.
        /// </returns>
        bool Navigate(Uri uri);

        /// <summary>
        ///     Displays the content located at the specified <see cref="IViewPageMappingItem"/>.
        /// </summary>
        /// <returns>
        ///     <c>true</c> if the content was successfully displayed; otherwise, <c>false</c>.
        /// </returns>
        /// <param name="source">
        ///     The <c>IViewPageMappingItem</c> of the content to display.
        /// </param>
        bool Navigate(IViewPageMappingItem source);

        /// <summary>
        ///     Navigates to the root page.
        /// </summary>
        bool NavigateToRoot();

        /// <summary>
        ///     Raised after navigation.
        /// </summary>
        event NavigatedEventHandler Navigated;

        /// <summary>
        ///     Raised prior to navigation.
        /// </summary>
        event NavigatingCancelEventHandler Navigating;

        /// <summary>
        ///     Raised when navigation fails.
        /// </summary>
        event NavigationFailedEventHandler NavigationFailed;

        /// <summary>
        ///     Raised when navigation is stopped.
        /// </summary>
        event NavigationStoppedEventHandler NavigationStopped;

        /// <summary>
        ///     Raised when a fragment navigation occurs.
        /// </summary>
        event FragmentNavigationEventHandler FragmentNavigation;
    }
}